package com.xxgc.wujiaolive.live;

import com.aizuda.zlm4j.core.ZLMApi;
import com.sun.jna.Native;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class LiveConfig {
    public static ZLMApi ZLM_API = Native.load("mk_api", ZLMApi.class);
    public void startLive(){
        log.info("直播服务启动中.......");
        //初始化sdk配置 SDK参数配置详见ZLM4J参数配置
        ZLM_API.mk_env_init2(1, 1, 1, null, 0, 0, null, 0, null, null);
        /**
         * 拉流用
         */
        //创建http服务器 0:失败,非0:端口号
        short http_server_port = ZLM_API.mk_http_server_start((short) 7788, 0);
        /**
         * 推流用
         */
        //创建rtmp服务器 0:失败,非0:端口号
        short rtmp_server_port = ZLM_API.mk_rtmp_server_start((short) 1935, 0);
        // HTTP-FLV拉流：http://ip:http_port/流APP/流名称.live.flv
        //创建rtsp服务器 0:失败,非0:端口号
        short rtsp_server_port = ZLM_API.mk_rtsp_server_start((short) 554, 0);
    }
}
